import Vue from "vue";
import VueRouter from 'vue-router'
Vue.use(VueRouter);

const routes = [
	{
		path: '/',
		redirect: '/login'
	},
	{
		name: 'Home',
		path: '/room',
		component: () => import('@/pages/room/index.vue')
	},
	{
		name: 'Login',
		path: '/login',
		component: () => import('@/pages/login/index.vue')
	},
	{
		name: 'List',
		path: '/list',
		component: () => import('@/pages/list/index.vue')
	}
]

// 3. 创建路由实例并传递 `routes` 配置
const router = new VueRouter({
	routes // `routes: routes` 的缩写
})

const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location, onResolve, onReject) {
	if (onResolve || onReject) return originalPush.call(this, location, onResolve, onReject)
	return originalPush.call(this, location).catch(err => err)
}


export default router;
